﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include "IGeometry.h"
#include "WeakReferenceable.h"

namespace gcmp
{
    class ITrimmedSurface;
    class IEdge;
    class ILoop;
    class IPolygon;

    /// \brief 拓扑面
    ///
    class IFace : public IGeometry, public WeakReferenceable
    {
    public:

        /// \brief   获取拓扑面对应的裁剪曲面
        /// \return  裁剪曲面
        virtual const ITrimmedSurface* GetTrimmedSurface()const = 0;

        /// \brief   获取拓扑面上环的数量
        /// \return  环的数量
        virtual int GetLoopCount() const = 0;

        /// \brief   获取拓扑面上所有的拓扑边
        /// \return  拓扑边数组
        virtual const std::vector<const IEdge*>& GetEdges() const = 0;

        /// \brief   设置拓扑面法向和几何曲面法向方向是否一致
        /// \param  sameDir   true一致,false相反
        /// \return  void
        virtual void SetOrientation(bool sameDir) = 0;

        /// \brief   判断拓扑面法向和几何曲面法向方向是否一致
        /// \return  一致返回True，否则返回False
        virtual bool GetOrientation() const = 0;

        /// \brief   判断拓扑面上的环(拷贝实现)
        /// \param int loopIndex   环的序号
        /// \return  环
        virtual OwnerPtr<ILoop> GetLoop(int loopIndex) const = 0;

        /// \brief  获取指定环上的拓扑边
        ///         其中loopIndex = 0时为外环，外环逆时针方向输出三维边; loopIndex > 0时为内环，内环顺时针方向输出三维边
        /// \param  loopIndex   环的序号
        /// \param  edges   拓扑边数组
        /// \param  edgeSameDirections   拓扑边与面上半边的方向是否同向
        /// \return  获取成功返回true，失败返回false
        virtual bool GetEdges(int loopIndex, std::vector<const IEdge*>& edges, std::vector<bool>& edgeSameDirections) const = 0;

        /// \brief  获取指定环上的拓扑边索引
        ///         其中loopIndex = 0时为外环，外环逆时针方向输出三维边; loopIndex > 0时为内环，内环顺时针方向输出三维边
        /// \param  loopIndex   环的序号
        /// \param  edges   拓扑边索引数组
        /// \param  edgeSameDirections   拓扑边与面上半边的方向是否同向
        /// \return  获取成功返回true，失败返回false
        virtual bool GetEdgeIndexes(int loopIndex, std::vector<int>& edgeIndexes, std::vector<bool>& edgeSameDirections) const = 0;

        /// \brief  获取面的标识
        /// \return  面的标识
        virtual int GetTag()const = 0;

        /// \brief  设置面的标识
        /// \param  tag   面的标识
        /// \return  成功返回true，失败返回false(默认返回true)
        virtual bool SetTag(int tag) = 0;


    public:
        virtual ~IFace() {}
    };
}